/*
 * Copyright 2011 Digia Oyj - Pasi Hirvonen <pasi.hirvonen@digia.fi>
 */

#ifndef RPCBASE64_H
#define RPCBASE64_H

#include <QtCore/QMetaType>
#include <QtCore/QObject>

namespace XmlRpc {

/*
 * Usage:
 * RpcBase64 base64 = RpcBase64("SGVsbG8gd29ybGQK");
 *
 * QString text(base64.decoded());
 *
 * text is now "hello world".
 */
class XmlRpcBase64 : public QObject
{
    Q_OBJECT
public:
    explicit XmlRpcBase64(QObject *parent = 0);
    XmlRpcBase64(const XmlRpcBase64 &other);
    XmlRpcBase64(const QByteArray &encoded);

    QByteArray encoded() const;
    QByteArray decoded() const;
    void setEncoded(const QByteArray &encoded);
    void setDecoded(const QByteArray &decoded);

    QString toString() const; // decoded

private:
    QByteArray m_bytes;
};

} // namespace XmlRpc

Q_DECLARE_METATYPE(XmlRpc::XmlRpcBase64)

#endif // RPCBASE64_H
